<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<infopost-request>
			<request-head>
				<trans-id>
					<xsl:value-of select="/BusinessTransactionRequest/BusinessTransaction/transationId"/>
				</trans-id>
				<trans-type>102</trans-type>
				<insu-id/>
				<trans-date>
					<xsl:value-of select="concat(substring(string(/BusinessTransactionRequest/BusinessTransaction/transationDate),1,4),substring(string(/BusinessTransactionRequest/BusinessTransaction/transationDate),6,2),substring(string(/BusinessTransactionRequest/BusinessTransaction/transationDate),9,2))"/>
				</trans-date>
				<trans-time>
					<xsl:value-of select="concat(substring(string(/BusinessTransactionRequest/BusinessTransaction/transationDate),12,2),substring(string(/BusinessTransactionRequest/BusinessTransaction/transationDate),15,2),substring(string(/BusinessTransactionRequest/BusinessTransaction/transationDate),18,2))"/>
				</trans-time>
				<area/>
				<bank/>
				<branch/>
				<post>
					<xsl:value-of select="/BusinessTransactionRequest/BusinessTransaction/partnerCode"/>
				</post>
				<agency-hand/>
				<authorized>life</authorized>
			</request-head>
			<request-newbiz>
				<request-underwriting>
					<application>
						<apply-code>
							<xsl:value-of select="/BusinessTransactionRequest/InsurancePolicy/applicationNumber"/>
						</apply-code>
						<policy-type>1</policy-type>
						<group-single>2</group-single>
						<branch-bank/>
						<agent-tel/>
						<pkg-unit/>
						<bank-code>
							<xsl:value-of select="/BusinessTransactionRequest/InsurancePolicy/bankCode"/>
						</bank-code>
						<sell-way>1</sell-way>
						<xsl:for-each select="/BusinessTransactionRequest/InsurancePolicy/Roles/Role">
							<xsl:choose>
								<xsl:when test="kind='PremiumAccount' ">
									<xsl:for-each select="Properties/Property">
										<xsl:choose>
											<xsl:when test="@kind='acctHolderName' ">
												<account-name>
													<xsl:value-of select="@value"/>
												</account-name>
												<acc-bankname>
													<xsl:value-of select="@value"/>
												</acc-bankname>
											</xsl:when>
											<xsl:when test="@kind='accountNumber' ">
												<bank-account>
													<xsl:value-of select="@value"/>
												</bank-account>
												<bank-accno>
													<xsl:value-of select="@value"/>
												</bank-accno>
											</xsl:when>
										</xsl:choose>
									</xsl:for-each>
								</xsl:when>
							</xsl:choose>
						</xsl:for-each>
						<account-type>2</account-type>
						<pay-mode>
							<xsl:value-of select="/BusinessTransactionRequest/InsurancePolicy/payMode"/>
						</pay-mode>
						<pay-next>
							<xsl:value-of select="/BusinessTransactionRequest/InsurancePolicy/payMode"/>
						</pay-next>
						<overdue-manage>1</overdue-manage>
						<over-manage>2</over-manage>
						<deliver-type>4</deliver-type>
						<currency-code>1</currency-code>
						<assumpsit/>
						<answer-type>1</answer-type>
						<answer-phone/>
						<answer-assumpsit/>
						<health-notice>Y</health-notice>
						<policy-pwd/>
						<print-code>
							<xsl:value-of select="/BusinessTransactionRequest/InsurancePolicy/externalReference"/>
						</print-code>
						<column1>
							<xsl:value-of select="/BusinessTransactionRequest/Order/orderNumber"/>
						</column1>
						<column2>
							<xsl:value-of select="/BusinessTransactionRequest/Order/currencyType"/>
						</column2>
						<premium/>
						<column3>
							<xsl:value-of select="/BusinessTransactionRequest/InsurancePolicy/isFree"/>
						</column3>
						<apply-date>
							<xsl:value-of select="concat(substring(string(/BusinessTransactionRequest/InsurancePolicy/appSignedDate),1,4),substring(string(/BusinessTransactionRequest/InsurancePolicy/appSignedDate),6,2),substring(string(/BusinessTransactionRequest/InsurancePolicy/appSignedDate),9,2))"/>
						</apply-date>
						<validate-date>
							<xsl:value-of select="concat(substring(string(/BusinessTransactionRequest/InsurancePolicy/appSignedDate),1,4),substring(string(/BusinessTransactionRequest/InsurancePolicy/appSignedDate),6,2),substring(string(/BusinessTransactionRequest/InsurancePolicy/appSignedDate),9,2))"/>
						</validate-date>
						<agency-code>
							<xsl:value-of select="/BusinessTransactionRequest/BusinessTransaction/agencyCode"/>
						</agency-code>
						<agency-hand/>
						<agent-name>
							<xsl:value-of select="/BusinessTransactionRequest/BusinessTransaction/agencyName"/>
						</agent-name>
						<policy-holder>
							<xsl:for-each select="/BusinessTransactionRequest/InsurancePolicy/Roles/Role">
								<xsl:choose>
									<xsl:when test="kind='Applicant' ">
										<xsl:for-each select="Properties/Property">
											<xsl:choose>
												<xsl:when test="@kind='fullName' ">
													<real-name>
														<xsl:value-of select="@value"/>
													</real-name>
												</xsl:when>
												<xsl:when test="@kind='gender' ">
													<xsl:choose>
														<xsl:when test="@value = 'M' ">
															<gender>M</gender>
														</xsl:when>
														<xsl:when test="@value = 'F' ">
															<gender>F</gender>
														</xsl:when>
														<xsl:otherwise>
															<gender>N</gender>
														</xsl:otherwise>
													</xsl:choose>
												</xsl:when>
												<xsl:when test="@kind='birthDate' ">
													<birthday>
														<xsl:value-of select="concat(substring(string(@value),1,4),substring(string(@value),6,2),substring(string(@value),9,2))"/>
													</birthday>
												</xsl:when>
												<xsl:when test="@kind='idType' ">
													<xsl:choose>
														<xsl:when test="@value = '1' ">
															<certi-type>1</certi-type>
															<nationality>37</nationality>
														</xsl:when>
														<xsl:when test="@value = '3' ">
															<certi-type>3</certi-type>
															<nationality>37</nationality>
														</xsl:when>
														<xsl:when test="@value = '6' ">
															<certi-type>6</certi-type>
															<nationality>37</nationality>
														</xsl:when>
														<xsl:when test="@value = '7' ">
															<certi-type>7</certi-type>
															<nationality>37</nationality>
														</xsl:when>
														<xsl:when test="@value = '8' ">
															<certi-type>8</certi-type>
															<nationality>37</nationality>
														</xsl:when>
														<xsl:otherwise>
															<certi-type>9</certi-type>
															<nationality/>
														</xsl:otherwise>
													</xsl:choose>
												</xsl:when>
												<xsl:when test="@kind='idNumber' ">
													<certi-code>
														<xsl:value-of select="@value"/>
													</certi-code>
												</xsl:when>
												<!--<xsl:when test="@kind='province' ">
                          <city-province>
                            <xsl:value-of select="@value"/>
                          </city-province>
                        </xsl:when>
                        <xsl:when test="@kind='city' ">
                          <district>
                            <xsl:value-of select="@value"/>
                          </district>
                        </xsl:when>-->
												<xsl:when test="@kind='email' ">
													<email>
														<xsl:value-of select="@value"/>
													</email>
												</xsl:when>
												<xsl:when test="@kind='phoneNumber' ">
													<celler>
														<xsl:value-of select="@value"/>
													</celler>
												</xsl:when>
												<!--<xsl:when test="@kind='postalCode' ">
                          <rela-zip>
                            <xsl:value-of select="@value"/>
                          </rela-zip>
                        </xsl:when>-->
												<xsl:when test="@kind='postalAddress' ">
													<rela-address>
														<xsl:value-of select="@value"/>
													</rela-address>
												</xsl:when>
												<!--<xsl:when test="@kind='jobCode' ">
                          <job-code>
                            <xsl:value-of select="@value"/>
                          </job-code>
                        </xsl:when>-->
												<xsl:when test="@kind='yearlyIncome' ">
													<yearly-income>
														<xsl:value-of select="@value"/>
													</yearly-income>
												</xsl:when>
												<xsl:when test="@kind='certiEndDate' ">
													<certi-end-date>
														<xsl:value-of select="@value"/>
													</certi-end-date>
												</xsl:when>
											</xsl:choose>
										</xsl:for-each>
									</xsl:when>
								</xsl:choose>
							</xsl:for-each>
							<marriage-id/>
							<race/>
							<homeplace/>
							<seat-address/>
							<certi-start-date/>
							<ward/>
							<day-phone/>
							<night-phone/>
							<pay-address/>
							<pay-zip/>
							<job-com/>
							<job-address/>
							<job-zip/>
							<industy/>
							<title/>
							<job-name/>
							<pt-job-name/>
							<relation-with-main-insured/>
							<smoking>N</smoking>
							<income-source/>
							<social-security/>
							<height/>
							<weight/>
							<valid-year/>
							<social-security-status/>
						</policy-holder>
						<life-assureds>
							<xsl:for-each select="/BusinessTransactionRequest/InsurancePolicy/Roles/Role">
								<xsl:choose>
									<xsl:when test="kind='Insured' ">
										<life-assured>
											<la-no>
												<xsl:number value="position()"/>
											</la-no>
											<xsl:call-template name="relatewWithPH">
												<xsl:with-param name="srcCode" select="/BusinessTransactionRequest/InsurancePolicy/Coverages/Coverage/LifeParticipant/InsuredApplicantRel"/>
											</xsl:call-template>
											<xsl:for-each select="Properties/Property">
												<xsl:choose>
													<xsl:when test="@kind='fullName' ">
														<real-name>
															<xsl:value-of select="@value"/>
														</real-name>
													</xsl:when>
													<xsl:when test="@kind='gender' ">
														<xsl:choose>
															<xsl:when test="@value = 'M' ">
																<gender>M</gender>
															</xsl:when>
															<xsl:when test="@value = 'F' ">
																<gender>F</gender>
															</xsl:when>
															<xsl:otherwise>
																<gender>N</gender>
															</xsl:otherwise>
														</xsl:choose>
													</xsl:when>
													<xsl:when test="@kind='birthDate' ">
														<birthday>
															<xsl:value-of select="concat(substring(string(@value),1,4),substring(string(@value),6,2),substring(string(@value),9,2))"/>
														</birthday>
													</xsl:when>
													<xsl:when test="@kind='idType' ">
														<xsl:choose>
															<xsl:when test="@value = '1' ">
																<certi-type>1</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:when test="@value = '3' ">
																<certi-type>3</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:when test="@value = '6' ">
																<certi-type>6</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:when test="@value = '7' ">
																<certi-type>7</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:when test="@value = '8' ">
																<certi-type>8</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:otherwise>
																<certi-type>9</certi-type>
																<nationality/>
															</xsl:otherwise>
														</xsl:choose>
													</xsl:when>
													<xsl:when test="@kind='idNumber' ">
														<certi-code>
															<xsl:value-of select="@value"/>
														</certi-code>
													</xsl:when>
													<xsl:when test="@kind='phoneNumber' ">
														<celler>
															<xsl:value-of select="@value"/>
														</celler>
													</xsl:when>
													<xsl:when test="@kind='postalAddress' ">
														<rela-address>
															<xsl:value-of select="@value"/>
														</rela-address>
													</xsl:when>
													<xsl:when test="@kind='yearlyIncome' ">
														<yearly-income>
															<xsl:value-of select="@value"/>
														</yearly-income>
													</xsl:when>
													<xsl:when test="@kind='certiEndDate' ">
														<certi-end-date>
															<xsl:value-of select="@value"/>
														</certi-end-date>
													</xsl:when>
												</xsl:choose>
											</xsl:for-each>
											<marriage-id/>
											<race/>
											<homeplace/>
											<seat-address/>
											<certi-start-date/>
											<city-province/>
											<district/>
											<ward/>
											<rela-zip/>
											<night-phone/>
											<day-phone/>
											<email/>
											<job-com/>
											<job-address/>
											<job-zip/>
											<industy/>
											<title/>
											<job-name/>
											<pt-job-name/>
											<job-code/>
											<smoking>N</smoking>
											<income-source/>
											<height/>
											<weight/>
											<valid-year/>
											<social-security/>
											<social-security-status/>
										</life-assured>
									</xsl:when>
								</xsl:choose>
							</xsl:for-each>
						</life-assureds>
						<beneficiaries>
							<xsl:for-each select="/BusinessTransactionRequest/InsurancePolicy/Roles/Role">
								<xsl:choose>
									<xsl:when test="kind='Beneficiary' ">
										<beneficiary>
											<la-no>
												<xsl:number value="position()"/>
											</la-no>
											<legal-bene-indi>Y</legal-bene-indi>
											<bene-is-empty>N</bene-is-empty>
											<xsl:for-each select="Properties/Property">
												<xsl:choose>
													<xsl:when test="@kind='fullName' ">
														<real-name>
															<xsl:value-of select="@value"/>
														</real-name>
													</xsl:when>
													<xsl:when test="@kind='gender' ">
														<xsl:choose>
															<xsl:when test="@value = 'M' ">
																<gender>M</gender>
															</xsl:when>
															<xsl:when test="@value = 'F' ">
																<gender>F</gender>
															</xsl:when>
															<xsl:otherwise>
																<gender>N</gender>
															</xsl:otherwise>
														</xsl:choose>
													</xsl:when>
													<xsl:when test="@kind='birthDate' ">
														<birthday>
															<xsl:value-of select="concat(substring(string(@value),1,4),substring(string(@value),6,2),substring(string(@value),9,2))"/>
														</birthday>
													</xsl:when>
													<xsl:when test="@kind='idType' ">
														<xsl:choose>
															<xsl:when test="@value = '1' ">
																<certi-type>1</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:when test="@value = '3' ">
																<certi-type>3</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:when test="@value = '6' ">
																<certi-type>6</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:when test="@value = '7' ">
																<certi-type>7</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:when test="@value = '8' ">
																<certi-type>8</certi-type>
																<nationality>37</nationality>
															</xsl:when>
															<xsl:otherwise>
																<certi-type>9</certi-type>
																<nationality/>
															</xsl:otherwise>
														</xsl:choose>
													</xsl:when>
													<xsl:when test="@kind='idNumber' ">
														<certi-code>
															<xsl:value-of select="@value"/>
														</certi-code>
													</xsl:when>
													<xsl:when test="@kind='postalAddress' ">
														<address>
															<xsl:value-of select="@value"/>
														</address>
													</xsl:when>
													<xsl:when test="@kind='certiEndDate' ">
														<certi-end-date>
															<xsl:value-of select="@value"/>
														</certi-end-date>
													</xsl:when>
												</xsl:choose>
											</xsl:for-each>
											<certi-start-date/>
											<bene-type>2</bene-type>
											<bene-order>1</bene-order>
											<bene-rate>100</bene-rate>
										</beneficiary>
									</xsl:when>
								</xsl:choose>
							</xsl:for-each>
						</beneficiaries>
						<products>
							<xsl:for-each select="/BusinessTransactionRequest/InsurancePolicy/Coverages/Coverage">
								<product>
									<la-no>
										<xsl:number value="position()"/>
									</la-no>
									<product-num>100</product-num>
									<external-prd-code>
										<xsl:value-of select="productCode"/>
									</external-prd-code>
									<product-name>
										<xsl:value-of select="name"/>
									</product-name>
									<is-waiver>N</is-waiver>
									<waiver-num/>
									<waiver-object/>
									<charge-mode>5</charge-mode>
									<pay-period>0</pay-period>
									<pay-year>0</pay-year>
									<end-period>0</end-period>
									<end-year>0</end-year>
									<pay-ensure>0</pay-ensure>
									<pay-type>0</pay-type>
									<xsl:for-each select="Properties/Property">
										<xsl:choose>
											<xsl:when test="@kind='unitCount' ">
												<unit>
													<xsl:value-of select="@value"/>
												</unit>
											</xsl:when>
											<xsl:when test="@kind='grossPremium' ">
												<discount-prem>
													<xsl:value-of select="@value"/>
												</discount-prem>
											</xsl:when>
											<xsl:when test="@kind='insuredAmount' ">
												<amount>
													<xsl:value-of select="@value"/>
												</amount>
											</xsl:when>
											<xsl:when test="@kind='chargePeriod' ">
												<charge-period>
													<xsl:value-of select="@value"/>
												</charge-period>
											</xsl:when>
											<xsl:when test="@kind='chargeYear' ">
												<charge-year>
													<xsl:value-of select="@value"/>
												</charge-year>
											</xsl:when>
											<xsl:when test="@kind='coveragePeriod' ">
												<coverage-period>
													<xsl:value-of select="@value"/>
												</coverage-period>
											</xsl:when>
											<xsl:when test="@kind='coverageYear' ">
												<coverage-year>
													<xsl:value-of select="@value"/>
												</coverage-year>
											</xsl:when>
											<xsl:when test="@kind='premium' ">
												<!-- 保费（单份）-->
												<column1>
													<xsl:value-of select="@value"/>
												</column1>
											</xsl:when>
											<xsl:when test="@kind='bonuspayMode' ">
												<!-- 红利派发方式-->
												<column2>
													<xsl:value-of select="@value"/>
												</column2>
											</xsl:when>
											<xsl:when test="@kind='sbpayMode' ">
												<!-- 生存金派发方式-->
												<column3>
													<xsl:value-of select="@value"/>
												</column3>
											</xsl:when>
											<xsl:when test="@kind='sbpayMode' ">
												<!-- 生存金派发方式-->
												<column4>
													<xsl:value-of select="@value"/>
												</column4>
											</xsl:when>
											<xsl:when test="@kind='issueDate' ">
												<!-- 核保时间-->
												<pay-date>
													<xsl:value-of select="concat(substring(string(@value),1,4),substring(string(@value),6,2),substring(string(@value),9,2))"/>
												</pay-date>
											</xsl:when>
											<xsl:when test="@kind='issueDate' ">
												<!-- 生效时间-->
												<column5>
													<xsl:value-of select="concat(substring(string(@value),1,4),substring(string(@value),6,2),substring(string(@value),9,2))"/>
												</column5>
											</xsl:when>
										</xsl:choose>
									</xsl:for-each>
									<count-way/>
									<bonus-choice/>
									<deduct/>
									<main-riskcode/>
									<password/>
									<rate/>
									<cvali-date/>
									<autopay-flag/>
									<bonuspay-mode/>
									<sub-flag/>
									<Iscash-autopay/>
									<Iscash-joininvest/>
									<health-flag/>
									<fullbonus-getmode/>
									<first-rate/>
									<sure-rate/>
									<end-date/>
								</product>
							</xsl:for-each>
						</products>
					</application>
				</request-underwriting>
			</request-newbiz>
		</infopost-request>
	</xsl:template>
	<xsl:template name="relatewWithPH">
		<xsl:param name="srcCode"/>
		<xsl:choose>
			<xsl:when test="$srcCode = 1 ">
				<relation-with-policy-holder>1</relation-with-policy-holder>
				<relation-with-main-insured>1</relation-with-main-insured>
			</xsl:when>
			<xsl:when test="$srcCode = 2">
				<relation-with-policy-holder>2</relation-with-policy-holder>
				<relation-with-main-insured>2</relation-with-main-insured>
			</xsl:when>
			<xsl:when test="$srcCode = 3">
				<relation-with-policy-holder>3</relation-with-policy-holder>
				<relation-with-main-insured>3</relation-with-main-insured>
			</xsl:when>
			<xsl:when test="$srcCode = 4">
				<relation-with-policy-holder>4</relation-with-policy-holder>
				<relation-with-main-insured>4</relation-with-main-insured>
			</xsl:when>
			<xsl:when test="$srcCode = 5">
				<relation-with-policy-holder>5</relation-with-policy-holder>
				<relation-with-main-insured>5</relation-with-main-insured>
			</xsl:when>
			<xsl:when test="$srcCode = 6">
				<relation-with-policy-holder>6</relation-with-policy-holder>
				<relation-with-main-insured>6</relation-with-main-insured>
			</xsl:when>
			<xsl:otherwise>
				<relation-with-policy-holder>7</relation-with-policy-holder>
				<relation-with-main-insured>7</relation-with-main-insured>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
